import java.util.Arrays;

/**
 * Created by qtbui on 2017/9/20.
 */
class Solution
{
    public int searchInsert(int[] nums, int target)
    {
        int pos= Arrays.binarySearch(nums,target);
        if(pos==-1)
        {
            pos=0;
        }
        else if(pos<0)
        {
            pos=(-pos)-1;
        }
        return pos;
    }
}

public class test
{
    public static void main(String[] args)
    {
        int[] nums=new int[] {1};
        int n = new Solution().searchInsert(nums,2);
        System.out.println(n);
    }
}
